SET_INT:
    pusha

    cli

    mov dx, es            ; Store original ES

    xor ax, ax            ; Clear AX for new ES value
    mov es, ax

    mov al, cl            ; Move supplied int into AL

    mov bl, 4            ; Multiply by four to get position
    mul bl                ; (Interrupt table = 4 byte sections)
    mov bx, ax

    mov [es:bx], si            ; First store offset
    add bx, 2

    mov ax, 0x2000            ; Then segment of our handler
    mov [es:bx], ax

    mov es, dx            ; Finally, restore data segment

    sti

    popa
    ret
	; ms-dos interrupt handlers
int21_ivt:
	cmp ah,0x02
	je near int21_chout
	cmp ah,0x09
	je near int21_print
int21_chout:
	push  ax			   ; Save AX
	mov ah,0x0E	
	mov   al,dl			   ; Put whats in dl into al
	int 0x10
	pop   ax			   ; Restore AX
	mov   al,dl			   ; Re-move, push AH dosen't want to work :O
	iret
int21_print:
	 pusha

    mov si, dx
    mov ah, 0Eh        ; int 10h teletype function

.repeat:
    lodsb            ; Get char from string
    cmp al, '$'
    je .done        ; If char is '$' character, end of string
    int 10h            ; Otherwise, print it
    jmp .repeat

.done:
    popa
    iret
int20_ivt: 
	; Terminates a program
	cmp dword [MODE],'CMDL'
	je .ok
	cmp dword [MODE],'PGUI'
	je .pcgui
.ok:
	call os_print_newline
	MOV SI,basic_finished_msg
	call os_print_string
	call os_wait_for_key
	call os_print_newline
	call CMD_RESTART
	mov dh, 0
	mov dl, 0
	call os_move_cursor
	jmp clear_screen			; When program has finished, start again
.pcgui:
	jmp load_pcgui